import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class Tester extends JFrame {
	private static final long serialVersionUID = 1L;
	private JTextField text_search = new JTextField("Kick Ass");
	private JTextArea text_result = new JTextArea();
	private JButton btn_search = new JButton("SUCHEN");
	private IMDB_Connector imdb_searcher = new IMDB_Connector();
	private JPanel mainPanel = new JPanel();
	
	public Tester(int width, int height) {
		this.getContentPane().setPreferredSize (new Dimension(width,height));
		this.getContentPane().add(mainPanel);
		
		mainPanel.setLayout(new BorderLayout());
		mainPanel.setSize(width,height);
		mainPanel.add(text_search, BorderLayout.NORTH);
		mainPanel.add(text_result, BorderLayout.CENTER);
		mainPanel.add(btn_search, BorderLayout.SOUTH);
		
		btn_search.addActionListener(new ActionListener() {	 
            public void actionPerformed(ActionEvent e)
            {
            	String searchstring = text_search.getText();
            	Movie movie = imdb_searcher.searchMovie(searchstring);
            	
            	text_result.setText(movie.toString());
            	System.out.println("Suche nach Filme '" + searchstring + "'");
            	System.out.println("Suche nach Filme Resultat '" + movie.getTitle() + "'");
            }
        });      
	}
	
	
}
